﻿package mortal.game.view.market.myQiugou
{
    import Message.Game.*;
    import flash.events.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.mvc.core.*;

    public class MarketMyQiugouPanel extends MarketMyMktBase
    {
        private static var _instance:MarketMyQiugouPanel;

        public function MarketMyQiugouPanel()
        {
            if (_instance)
            {
                throw new Error("MarketMyQiugouPanel单例");
            }
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.resetUI();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            NetDispatcher.removeCmdListener(ServerCommand.MarketCancelSeekBuy, this.cancelBack);
            NetDispatcher.removeCmdListener(ServerCommand.MarketGetMySeekBuysBack, this.mySeekBuysUpdate);
            return;
        }// end function

        override protected function resetUI() : void
        {
            this._title1.text = "我求购的物品";
            _pageSelect.configEventListener(Event.CHANGE, this.onPageChange);
            NetDispatcher.addCmdListener(ServerCommand.MarketCancelSeekBuy, this.cancelBack);
            NetDispatcher.addCmdListener(ServerCommand.MarketGetMySeekBuysBack, this.mySeekBuysUpdate);
            this.getDataFromServer();
            this.mySeekBuysUpdate();
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            this.updatePanel(Cache.instance.market.mySeekBuyMarketItemObj);
            return;
        }// end function

        public function getDataFromServer() : void
        {
            var _loc_1:Object = {};
            _loc_1.recordType = EMarketRecordType._EMarketRecordSeekBuy;
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarketGetMyRecords, _loc_1));
            return;
        }// end function

        private function mySeekBuysUpdate(param1:Object = null) : void
        {
            this.updatePanel(Cache.instance.market.mySeekBuyMarketItemObj);
            return;
        }// end function

        private function cancelBack(param1:Object) : void
        {
            this.getDataFromServer();
            return;
        }// end function

        public static function get instance() : MarketMyQiugouPanel
        {
            if (_instance == null)
            {
                _instance = new MarketMyQiugouPanel;
            }
            return _instance;
        }// end function

    }
}
